<?php
/**
*
* @package phpBB3 stockvirtual
* @version $Id$
* @copyright (c) 2005 phpBB Group, 2011 Minway Hsu
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

// list the corps in which the user may be interested .
function handle_personal_setting($user_id)
{
	global $db;	
	
	// set default value.
	$news_max_number = 10;
	$market_info_option = 0;
	
	// Basic parameter data
	$mode		= $db->sql_escape(request_var('mode', ''));
	
	if ($mode == 'set_belief')
	{
		$belief	= $db->sql_escape(utf8_clean_string(request_var('belief', '', true)));
		
		// set belief
		$holder_list = false;
	
		$sql 	= 'UPDATE sv_personal_setting SET belief="' . $belief . '" WHERE user_id=' . $user_id ;
		$result = $db->sql_query($sql);	
	}
	else if ($mode == 'set_news_max_number')
	{
		$news_max_number = (int)request_var('news_max_number', 0, true);
		
		if ($news_max_number >= 0 && $news_max_number <= 100)
		{
			$sql 	= 'UPDATE sv_personal_setting SET news_max_number="' . $news_max_number . '" WHERE user_id=' . $user_id ;
			$result = $db->sql_query($sql);	
		}
	}
	else if ($mode == 'set_market_info')
	{
		$market_info_option = (int)(request_var('market_info_option', 0, true));
		
		if ($market_info_option >= 0 && $market_info_option <= 2)
		{
			$sql 	= 'UPDATE sv_personal_setting SET market_info="' . $market_info_option . '" WHERE user_id=' . $user_id ;
			$result = $db->sql_query($sql);	
		}
	}
	else if ($mode == 'set_delegation_list_info')
	{
		$delegation_list_info_option = (int)request_var('delegation_list_info_option', 0, true);
		
		if ($delegation_list_info_option >= 0 && $delegation_list_info_option <= 1)
		{
			$sql 	= 'UPDATE sv_personal_setting SET delegation_list_info="' . $delegation_list_info_option . '" WHERE user_id=' . $user_id ;
			$result = $db->sql_query($sql);	
		}
	}
	else if ($mode == 'set_allow_ad')
	{
		$allow_ad_option = (int)request_var('allow_ad_option', 0, true);
		
		if ($allow_ad_option >= 0 && $allow_ad_option <= 1)
		{
			$sql 	= 'UPDATE sv_personal_setting SET allow_ad="' . $allow_ad_option . '" WHERE user_id=' . $user_id ;
			$result = $db->sql_query($sql);	
		}
	}

}

?>